namespace QMVnSoft.ReportForms
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormKTH02TUViewer : FormReportViewer
    {
        private IContainer components;
        private LabelControl lblMa_Dt;
        private LabelControl lblMa_Dt_Du;
        private LabelControl lblNgay_Ct1;
        private LabelControl lblNgay_Ct2;
        private LabelControl lblTk;
        private TextSearch txtMa_Dt;
        private TextSearch txtMa_Nh_Dt;
        private TextDate txtNgay_Ct1;
        private TextDate txtNgay_Ct2;
        private TextControl txtTen_Dt;
        private TextControl txtTen_Nh_Dt;
        private TextControl txtTen_Tk;
        private TextSearch txtTk;

        public FormKTH02TUViewer()
        {
            this.InitializeComponent();
            this.txtTk.Value = "141";
            this.txtNgay_Ct1.Value = AppInstance.StartWorkingDate;
            this.txtNgay_Ct2.Value = AppInstance.EndWorkingDate;
        }

        public FormKTH02TUViewer(object pd_Ngay_Ct1, object pd_Ngay_Ct2, object ps_Tk, object ps_Ma_Dt, object ps_Ma_Nh_Dt, object pi_Loai_Tte)
        {
            this.InitializeComponent();
            this.txtNgay_Ct1.Value = pd_Ngay_Ct1;
            this.txtNgay_Ct2.Value = pd_Ngay_Ct2;
            this.txtTk.Value = ps_Tk;
            this.txtMa_Dt.Value = ps_Ma_Dt;
            this.txtMa_Nh_Dt.Value = ps_Ma_Nh_Dt;
            this.txtTen_Tk.Value = this.txtTk.GetFieldData("Ten_Tk");
            this.txtTen_Dt.Value = this.txtMa_Dt.GetFieldData("Ten_Dt");
            this.txtTen_Nh_Dt.Value = this.txtMa_Nh_Dt.GetFieldData("Ten_Nh_Dt");
            this.OnMakeReport();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            //ComponentResourceManager manager = new ComponentResourceManager(typeof(FormKTH02TUViewer));
            this.txtTen_Tk = new TextControl();
            this.txtTk = new TextSearch();
            this.lblTk = new LabelControl();
            this.txtTen_Dt = new TextControl();
            this.txtMa_Dt = new TextSearch();
            this.lblMa_Dt = new LabelControl();
            this.lblMa_Dt_Du = new LabelControl();
            this.txtMa_Nh_Dt = new TextSearch();
            this.txtTen_Nh_Dt = new TextControl();
            this.txtNgay_Ct2 = new TextDate();
            this.lblNgay_Ct2 = new LabelControl();
            this.txtNgay_Ct1 = new TextDate();
            this.lblNgay_Ct1 = new LabelControl();
            base.rptContainer.Panel1.SuspendLayout();
            base.rptContainer.SuspendLayout();
            base.SuspendLayout();
            base.rptContainer.Panel1.Controls.Add(this.txtNgay_Ct2);
            base.rptContainer.Panel1.Controls.Add(this.lblNgay_Ct2);
            base.rptContainer.Panel1.Controls.Add(this.txtNgay_Ct1);
            base.rptContainer.Panel1.Controls.Add(this.lblNgay_Ct1);
            base.rptContainer.Panel1.Controls.Add(this.txtTen_Nh_Dt);
            base.rptContainer.Panel1.Controls.Add(this.txtTen_Dt);
            base.rptContainer.Panel1.Controls.Add(this.txtMa_Nh_Dt);
            base.rptContainer.Panel1.Controls.Add(this.lblMa_Dt_Du);
            base.rptContainer.Panel1.Controls.Add(this.txtMa_Dt);
            base.rptContainer.Panel1.Controls.Add(this.lblMa_Dt);
            base.rptContainer.Panel1.Controls.Add(this.txtTen_Tk);
            base.rptContainer.Panel1.Controls.Add(this.txtTk);
            base.rptContainer.Panel1.Controls.Add(this.lblTk);
            base.rptContainer.SplitterDistance = 0x58;
            this.txtTen_Tk.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtTen_Tk.BackColor = SystemColors.Control;
            this.txtTen_Tk.BorderStyle = BorderStyle.None;
            this.txtTen_Tk.CheckTextSearched = false;
            this.txtTen_Tk.DisabledForeColor = Color.Blue;
            this.txtTen_Tk.Enabled = false;
            this.txtTen_Tk.Font = new Font("Arial", 8.25f);
            this.txtTen_Tk.ForeColor = Color.Blue;
            this.txtTen_Tk.Location = new Point(0xd6, 6);
            this.txtTen_Tk.Name = "txtTen_Tk";
            this.txtTen_Tk.OldValue = null;
            this.txtTen_Tk.Size = new Size(0x1ca, 13);
            this.txtTen_Tk.TabIndex = 1;
//            this.txtTen_Tk.Value = null;//manager.GetObject("txtTen_Tk.Value");
            this.txtTk.CharacterCasing = CharacterCasing.Upper;
            this.txtTk.CheckTextSearched = false;
            this.txtTk.DisabledForeColor = Color.Empty;
            this.txtTk.FieldDisplay = "Ten_Tk";
            this.txtTk.Font = new Font("Arial", 8.25f);
            this.txtTk.FoundIsValid = true;
            this.txtTk.Location = new Point(0x6c, 3);
            this.txtTk.MaxLength = 0x20;
            this.txtTk.Name = "txtTk";
            this.txtTk.OldValue = null;
            this.txtTk.Size = new Size(100, 20);
            this.txtTk.TabIndex = 0;
            this.txtTk.TableName = "DMTK";
            this.txtTk.TextDisplay = this.txtTen_Tk;
            this.txtTk.UserTextLength = AppInstance.TextControlLength.ItemCode;
            this.txtTk.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtTk.Value = null;//manager.GetObject("txtTk.Value");
            this.lblTk.AutoSize = true;
            this.lblTk.Font = new Font("Arial", 8.25f);
            this.lblTk.Location = new Point(12, 6);
            this.lblTk.Name = "lblTk";
            this.lblTk.Size = new Size(0x35, 14);
            this.lblTk.TabIndex = 0x57;
            this.lblTk.Text = "Tài khoản";
            this.txtTen_Dt.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtTen_Dt.BackColor = SystemColors.Control;
            this.txtTen_Dt.BorderStyle = BorderStyle.None;
            this.txtTen_Dt.CheckTextSearched = false;
            this.txtTen_Dt.DisabledForeColor = Color.Blue;
            this.txtTen_Dt.Enabled = false;
            this.txtTen_Dt.Font = new Font("Arial", 8.25f);
            this.txtTen_Dt.ForeColor = Color.Blue;
            this.txtTen_Dt.Location = new Point(0xd6, 0x31);
            this.txtTen_Dt.Name = "txtTen_Dt";
            this.txtTen_Dt.OldValue = null;
            this.txtTen_Dt.Size = new Size(0x1ca, 13);
            this.txtTen_Dt.TabIndex = 3;
//            this.txtTen_Dt.Value = null;//manager.GetObject("txtTen_Dt.Value");
            this.txtMa_Dt.CharacterCasing = CharacterCasing.Upper;
            this.txtMa_Dt.CheckTextSearched = false;
            this.txtMa_Dt.DisabledForeColor = Color.Empty;
            this.txtMa_Dt.EmptyIsValid = true;
            this.txtMa_Dt.FieldDisplay = "Ten_Dt";
            this.txtMa_Dt.Font = new Font("Arial", 8.25f);
            this.txtMa_Dt.FoundIsValid = true;
            this.txtMa_Dt.Location = new Point(0x6c, 0x2d);
            this.txtMa_Dt.MaxLength = 0x20;
            this.txtMa_Dt.Name = "txtMa_Dt";
            this.txtMa_Dt.OldValue = null;
            this.txtMa_Dt.Size = new Size(100, 20);
            this.txtMa_Dt.TabIndex = 2;
            this.txtMa_Dt.TableName = "DMDT";
            this.txtMa_Dt.TextDisplay = this.txtTen_Dt;
            this.txtMa_Dt.UserTextLength = AppInstance.TextControlLength.ItemCode;
            this.txtMa_Dt.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtMa_Dt.Value = null;//manager.GetObject("txtMa_Dt.Value");
            this.lblMa_Dt.AutoSize = true;
            this.lblMa_Dt.Font = new Font("Arial", 8.25f);
            this.lblMa_Dt.Location = new Point(12, 0x30);
            this.lblMa_Dt.Name = "lblMa_Dt";
            this.lblMa_Dt.Size = new Size(0x37, 14);
            this.lblMa_Dt.TabIndex = 0x5e;
            this.lblMa_Dt.Text = "Đối tượng";
            this.lblMa_Dt_Du.AutoSize = true;
            this.lblMa_Dt_Du.Font = new Font("Arial", 8.25f);
            this.lblMa_Dt_Du.Location = new Point(12, 0x1b);
            this.lblMa_Dt_Du.Name = "lblMa_Dt_Du";
            this.lblMa_Dt_Du.Size = new Size(0x53, 14);
            this.lblMa_Dt_Du.TabIndex = 0x5e;
            this.lblMa_Dt_Du.Text = "Nhóm đối tượng";
            this.txtMa_Nh_Dt.CharacterCasing = CharacterCasing.Upper;
            this.txtMa_Nh_Dt.CheckTextSearched = false;
            this.txtMa_Nh_Dt.DisabledForeColor = Color.Empty;
            this.txtMa_Nh_Dt.EmptyIsValid = true;
            this.txtMa_Nh_Dt.FieldDisplay = "Ten_Nh_Dt";
            this.txtMa_Nh_Dt.Font = new Font("Arial", 8.25f);
            this.txtMa_Nh_Dt.FoundIsValid = true;
            this.txtMa_Nh_Dt.Location = new Point(0x6c, 0x18);
            this.txtMa_Nh_Dt.MaxLength = 0x20;
            this.txtMa_Nh_Dt.Name = "txtMa_Nh_Dt";
            this.txtMa_Nh_Dt.OldValue = null;
            this.txtMa_Nh_Dt.Size = new Size(100, 20);
            this.txtMa_Nh_Dt.TabIndex = 1;
            this.txtMa_Nh_Dt.TableName = "DMNHDT";
            this.txtMa_Nh_Dt.TextDisplay = this.txtTen_Nh_Dt;
            this.txtMa_Nh_Dt.UserTextLength = AppInstance.TextControlLength.ItemCode;
            this.txtMa_Nh_Dt.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtMa_Nh_Dt.Value = null;//manager.GetObject("txtMa_Nh_Dt.Value");
            this.txtTen_Nh_Dt.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtTen_Nh_Dt.BackColor = SystemColors.Control;
            this.txtTen_Nh_Dt.BorderStyle = BorderStyle.None;
            this.txtTen_Nh_Dt.CheckTextSearched = false;
            this.txtTen_Nh_Dt.DisabledForeColor = Color.Blue;
            this.txtTen_Nh_Dt.Enabled = false;
            this.txtTen_Nh_Dt.Font = new Font("Arial", 8.25f);
            this.txtTen_Nh_Dt.ForeColor = Color.Blue;
            this.txtTen_Nh_Dt.Location = new Point(0xd6, 0x1c);
            this.txtTen_Nh_Dt.Name = "txtTen_Nh_Dt";
            this.txtTen_Nh_Dt.OldValue = null;
            this.txtTen_Nh_Dt.Size = new Size(0x1ca, 13);
            this.txtTen_Nh_Dt.TabIndex = 5;
//            this.txtTen_Nh_Dt.Value = null;//manager.GetObject("txtTen_Nh_Dt.Value");
            this.txtNgay_Ct2.DateTimeFormat = TextDate.DateTimeFormatType.Date;
            this.txtNgay_Ct2.Font = new Font("Arial", 8.25f);
            this.txtNgay_Ct2.InsertKeyMode = InsertKeyMode.Overwrite;
            this.txtNgay_Ct2.Location = new Point(0x13c, 0x42);
            this.txtNgay_Ct2.Mask = "00/00/0000";
            this.txtNgay_Ct2.Name = "txtNgay_Ct2";
            this.txtNgay_Ct2.OldValue = null;
            this.txtNgay_Ct2.Size = new Size(100, 20);
            this.txtNgay_Ct2.TabIndex = 4;
//            this.txtNgay_Ct2.Value = null;//manager.GetObject("txtNgay_Ct2.Value");
            this.lblNgay_Ct2.AutoSize = true;
            this.lblNgay_Ct2.Font = new Font("Arial", 8.25f);
            this.lblNgay_Ct2.Location = new Point(0x100, 0x45);
            this.lblNgay_Ct2.Name = "lblNgay_Ct2";
            this.lblNgay_Ct2.Size = new Size(0x36, 14);
            this.lblNgay_Ct2.TabIndex = 0x61;
            this.lblNgay_Ct2.Text = "Đến ngày";
            this.txtNgay_Ct1.DateTimeFormat = TextDate.DateTimeFormatType.Date;
            this.txtNgay_Ct1.Font = new Font("Arial", 8.25f);
            this.txtNgay_Ct1.InsertKeyMode = InsertKeyMode.Overwrite;
            this.txtNgay_Ct1.Location = new Point(0x6c, 0x42);
            this.txtNgay_Ct1.Mask = "00/00/0000";
            this.txtNgay_Ct1.Name = "txtNgay_Ct1";
            this.txtNgay_Ct1.OldValue = null;
            this.txtNgay_Ct1.Size = new Size(100, 20);
            this.txtNgay_Ct1.TabIndex = 3;
//            this.txtNgay_Ct1.Value = null;//manager.GetObject("txtNgay_Ct1.Value");
            this.lblNgay_Ct1.AutoSize = true;
            this.lblNgay_Ct1.Font = new Font("Arial", 8.25f);
            this.lblNgay_Ct1.Location = new Point(12, 0x45);
            this.lblNgay_Ct1.Name = "lblNgay_Ct1";
            this.lblNgay_Ct1.Size = new Size(0x2f, 14);
            this.lblNgay_Ct1.TabIndex = 0x62;
            this.lblNgay_Ct1.Text = "Từ ngày";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.ClientSize = new Size(0x31a, 0x1cf);
            base.Name = "FormKTH02TUViewer";
            base.rptContainer.Panel1.ResumeLayout(false);
            base.rptContainer.Panel1.PerformLayout();
            base.rptContainer.ResumeLayout(false);
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        protected override void OnGenerateColumns()
        {
            if (base.CurrencyIndex == 0)
            {
                object[][] objArray = new object[8][];
                object[] objArray2 = new object[4];
                objArray2[0] = "Ma_Dt";
                objArray2[1] = "Mã đối tượng ";
                objArray2[2] = "C";
                objArray[0] = objArray2;
                object[] objArray3 = new object[4];
                objArray3[0] = "Ten_Dt";
                objArray3[1] = "Tên đối tượng";
                objArray3[2] = "C";
                objArray[1] = objArray3;
                objArray[2] = new object[] { "Du_No1", "Dư nợ đầu", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray[3] = new object[] { "Du_Co1", "Dư có đầu", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray[4] = new object[] { "Ps_No", "Phát sinh nợ", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray[5] = new object[] { "Ps_Co", "Phát sinh có", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray[6] = new object[] { "Du_No2", "Dư nợ cuối", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray[7] = new object[] { "Du_Co2", "Dư có cuối", "N", AppInstance.TextNumericFormat.LocalAmount };
                base.LocalColNames = objArray;
                base.OnGenerateColumns();
            }
            else
            {
                object[][] objArray10 = new object[8][];
                object[] objArray11 = new object[4];
                objArray11[0] = "Ma_Dt";
                objArray11[1] = "Mã đối tượng ";
                objArray11[2] = "C";
                objArray10[0] = objArray11;
                object[] objArray12 = new object[4];
                objArray12[0] = "Ten_Dt";
                objArray12[1] = "Tên đối tượng";
                objArray12[2] = "C";
                objArray10[1] = objArray12;
                objArray10[2] = new object[] { "Du_No_Nt1", "Dư nợ đầu", "N", AppInstance.TextNumericFormat.ForeignAmount };
                objArray10[3] = new object[] { "Du_Co_Nt1", "Dư có đầu", "N", AppInstance.TextNumericFormat.ForeignAmount };
                objArray10[4] = new object[] { "Ps_No_Nt", "Ps nợ", "N", AppInstance.TextNumericFormat.ForeignAmount };
                objArray10[5] = new object[] { "Ps_Co_Nt", "Ps có", "N", AppInstance.TextNumericFormat.ForeignAmount };
                objArray10[6] = new object[] { "Du_No_Nt2", "Dư nợ cuối", "N", AppInstance.TextNumericFormat.ForeignAmount };
                objArray10[7] = new object[] { "Du_Co_Nt2", "Dư có cuối", "N", AppInstance.TextNumericFormat.ForeignAmount };
                base.ForeignColNames = objArray10;
                base.OnGenerateColumns();
            }
        }

        protected override void OnMakeReport()
        {
            AppInstance.StartWorkingDate = (DateTime) this.txtNgay_Ct1.Value;
            AppInstance.EndWorkingDate = (DateTime) this.txtNgay_Ct2.Value;
            this.OnGenerateColumns();
            base.LocalTable = new ReportDataAccess().KTH02_Get(AppInstance.Subsidiaries, this.txtNgay_Ct1.Value, this.txtNgay_Ct2.Value, this.txtTk.Value, this.txtMa_Dt.Value, this.txtMa_Nh_Dt.Value, AppInstance.DefLanguage);
            base.OnMakeReport();
        }

        protected override void OnSendParameters()
        {
            base.StimulReport["Ngay"] = "Từ ngày " + string.Format("{0:dd/MM/yyyy}", this.txtNgay_Ct1.Value) + " đến ngày " + string.Format("{0:dd/MM/yyyy}", this.txtNgay_Ct2.Value);
            if (string.IsNullOrEmpty(this.txtTk.Value.ToString()))
            {
                base.StimulReport["TaiKhoan"] = "";
            }
            else
            {
                base.StimulReport["TaiKhoan"] = string.Concat(new object[] { "Tài khoản: ", this.txtTen_Tk.Value, " (", this.txtTk.Value, ")" });
            }
            if (string.IsNullOrEmpty(this.txtMa_Nh_Dt.Value.ToString()))
            {
                base.StimulReport["NhomDoiTuong"] = "";
            }
            else
            {
                base.StimulReport["NhomDoiTuong"] = string.Concat(new object[] { "Nhóm đối tượng: ", this.txtTen_Nh_Dt.Value, " (", this.txtMa_Nh_Dt.Value, ")" });
            }
            if (string.IsNullOrEmpty(this.txtMa_Dt.Value.ToString()))
            {
                base.StimulReport["DoiTuong"] = "";
            }
            else
            {
                base.StimulReport["DoiTuong"] = string.Concat(new object[] { "Đối tượng: ", this.txtTen_Dt.Value, " (", this.txtMa_Dt.Value, ")" });
            }
        }

        protected override void OnShowDetail()
        {
            object obj2 = ((DataRowView) base.DataGridBrowser.CurrentRow.DataBoundItem).Row["Ma_Dt"];
            if (!string.IsNullOrEmpty(obj2.ToString()))
            {
                FormKCT04TUViewer viewer = new FormKCT04TUViewer(this.txtNgay_Ct1.Value, this.txtNgay_Ct2.Value, this.txtTk.Value, obj2, this.txtMa_Nh_Dt.Value, base.CurrencyIndex);
                viewer.TitleText = "Sổ chi tiết phải trả cho người bán";
                viewer.ReportTitle = "Sổ chi tiết phải trả cho người bán";
                viewer.ReportFile = "KCT04";
                viewer.Show();
            }
        }
    }
}

